package com.hzit.security.handler;

import com.alibaba.fastjson.JSON;
import com.hzit.util.R;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.awt.image.ReplicateScaleFilter;
import java.io.IOException;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
public class HzitAuthenticationEntryPoint implements AuthenticationEntryPoint {
	@Override
	public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
		response.setContentType("text/html;charset=utf8");
		R<Object> fail = R.fail("认证失败！");
		response.getWriter().println(JSON.toJSONString(fail));
		response.getWriter().flush();
	}
}
